// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.audio.parameters;

import fmod.fmod.FMODManager;
import zombie.audio.FMODLocalParameter;
import zombie.characters.IsoGameCharacter;
import zombie.characters.IsoPlayer;
import zombie.core.properties.PropertyContainer;
import zombie.iso.IsoGridSquare;
import zombie.iso.IsoObject;
import zombie.iso.SpriteDetails.IsoFlagType;
import zombie.iso.objects.IsoWorldInventoryObject;
import zombie.util.list.PZArrayList;

public final class ParameterFootstepMaterial extends FMODLocalParameter {
    private final IsoGameCharacter character;

    public ParameterFootstepMaterial(IsoGameCharacter _character) {
        super("FootstepMaterial");
        this.character = _character;
    }

    @Override
    public float calculateCurrentValue() {
        return (float)this.getMaterial().label;
    }

    private ParameterFootstepMaterial.FootstepMaterial getMaterial() {
        if (FMODManager.instance.getNumListeners() == 1) {
            for (int int0 = 0; int0 < IsoPlayer.numPlayers; int0++) {
                IsoPlayer isoPlayer = IsoPlayer.players[int0];
                if (isoPlayer != null && isoPlayer != this.character && !isoPlayer.Traits.Deaf.isSet()) {
                    if ((int)isoPlayer.getZ() < (int)this.character.getZ()) {
                        return ParameterFootstepMaterial.FootstepMaterial.Upstairs;
                    }
                    break;
                }
            }
        }

        Object object = null;
        IsoObject isoObject0 = null;
        IsoGridSquare isoGridSquare = this.character.getCurrentSquare();
        if (isoGridSquare != null) {
            PZArrayList pZArrayList = isoGridSquare.getObjects();

            for (int int1 = 0; int1 < pZArrayList.size(); int1++) {
                IsoObject isoObject1 = (IsoObject)pZArrayList.get(int1);
                if (!(isoObject1 instanceof IsoWorldInventoryObject)) {
                    PropertyContainer propertyContainer = isoObject1.getProperties();
                    if (propertyContainer != null) {
                        if (propertyContainer.Is(IsoFlagType.solidfloor)) {
                            ;
                        }

                        if (propertyContainer.Is("FootstepMaterial")) {
                            isoObject0 = isoObject1;
                        }
                    }
                }
            }
        }

        if (isoObject0 != null) {
            try {
                String string = isoObject0.getProperties().Val("FootstepMaterial");
                return ParameterFootstepMaterial.FootstepMaterial.valueOf(string);
            } catch (IllegalArgumentException illegalArgumentException) {
                boolean _boolean = true;
            }
        }

        return ParameterFootstepMaterial.FootstepMaterial.Concrete;
    }

    static enum FootstepMaterial {
        Upstairs(0),
        BrokenGlass(1),
        Concrete(2),
        Grass(3),
        Gravel(4),
        Puddle(5),
        Snow(6),
        Wood(7),
        Carpet(8),
        Dirt(9),
        Sand(10),
        Ceramic(11),
        Metal(12);

        final int label;

        private FootstepMaterial(int int1) {
            this.label = int1;
        }
    }
}
